package com.thinkgem.jeesite.modules.borrow.entity;

import com.thinkgem.jeesite.common.persistence.DataEntity;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.utils.excel.annotation.ExcelField;
import com.thinkgem.jeesite.modules.book.entity.BkBookinfo;
import com.thinkgem.jeesite.modules.book.entity.BkBookstore;
import com.thinkgem.jeesite.modules.reader.entity.Reader;
import com.thinkgem.jeesite.modules.reader.entity.ReaderRoler;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;

import java.util.Date;

/**
 * 读者Entity
 * Created by liu_pc on 2015-10-29.
 */
public class Borrow extends DataEntity<Borrow> {

    private String zlId; // 借阅编号（用于扫描码，设置规则需要）

    private String rdId; // 用户编号

    private String userName; // 操作用户
    private String remarks; //备注
    private String status; //借出状态 1：借出中;0：已还
    private String source; //借阅来源

    private String returnStatus; // 借出状态 1：借出中;0：已还
    private String rdCardno;// 图书证号
    private String rdiccardno;// IC卡号
    private String isbn;// ISBN
    private String bkId; // 书籍编号（该处为书籍的banid）
    private String bookname;// 书名

    private String classcode;//分类号

    private String place;//索书号

    private String readername;//读者姓名

    private String rdRoleId;//读者角色

    private Date borDate; //借出日期
    private Date rtnDate; //归还日期
    private Date needRtnDate; //应还日期
    private String contCnt; //续借次数

    private ReaderRoler readerRoler;

    private Reader reader;

    private BkBookinfo bkBookinfo;

    private BkBookstore bkBookstore;

    private Date currentDate;		// 当前日期
    private Date beginDate;		// 开始日期
    private Date endDate;		// 结束日期
    private String searchCondition;		// 当前流通查询条件

    public Borrow(String zlId, String bkId, String rdId, Date borDate, Date rtnDate,
                  String contCnt, String userName, String remarks, String status, String isbn,
                  ReaderRoler readerRoler, Reader reader, BkBookinfo bkBookinfo,
                  BkBookstore bkBookstore, String rdCardno, Date needRtnDate,
                  String returnStatus, String rdiccardno) {
        this.zlId = zlId;
        this.bkId = bkId;
        this.rdId = rdId;
        this.borDate = borDate;
        this.rtnDate = rtnDate;
        this.contCnt = contCnt;
        this.userName = userName;
        this.remarks = remarks;
        this.status = status;
        this.isbn = isbn;
        this.readerRoler = readerRoler;
        this.reader = reader;
        this.bkBookinfo = bkBookinfo;
        this.bkBookstore = bkBookstore;
        this.rdCardno = rdCardno;
        this.needRtnDate=needRtnDate;
        this.rdiccardno = rdiccardno;
    }

    public String getId() {
        return id;
    }

    // -------------------------------------------------------------------------------
    @ExcelField(title = "借书证号", type = 1, align = 2, sort = 10)
    public String getRdCardnoStr(){
        return reader.getRdCardno();
    }
    @ExcelField(title = "一卡通号", type = 1, align = 2, sort = 20)
    public String getRdIccardno(){
        return reader.getRdIccardno();
    }

    @ExcelField(title = "读者姓名", type = 1, align = 2, sort = 30)
    public String getRdName(){
        return reader.getRdName();
    }

    @ExcelField(title = "联系电话", type = 1, align = 2, sort = 40)
    public String getRdTele(){
        return reader.getRdTele();
    }

    @ExcelField(title = "图书条码", type = 1, align = 2, sort = 50)
    public String getBanid(){
        return bkBookstore.getBanid();
    }

    @ExcelField(title = "资料名称", type = 1, align = 2, sort = 60)
    public String getBooknameStr(){
        String bookname = bkBookinfo.getBookname();
        String othername = bkBookinfo.getOthername();
        if(StringUtils.isNotEmpty(othername)){
            bookname = bookname + "-" + othername;
        }
        return bookname;
    }

    @ExcelField(title = "价格", type = 1, align = 2, sort = 70)
    public String getPrice(){
        return bkBookstore.getPrice();
    }

    @ExcelField(title = "ISBN", type = 1, align = 2, sort = 80)
    public String getIsbnStr(){
        return bkBookinfo.getIsbn();
    }

    @ExcelField(title = "索书号", type = 1, align = 2, sort = 90)
    public String getPlaceStr(){
        return bkBookstore.getClasscode() + "/" + bkBookstore.getPlace();
    }

    @ExcelField(title = "借出日期", type = 1, align = 2, sort = 100)
    public String getBorDateStr(){
        return DateUtils.formatDate(borDate);
    }

    @ExcelField(title = "应还日期", type = 1, align = 2, sort = 110)
    public String getNeedRtnDateStr(){
        return DateUtils.formatDate(needRtnDate);
    }

    @ExcelField(title = "归还日期", type = 1, align = 2, sort = 120)
    public String getRtnDateStr(){
        return DateUtils.formatDate(rtnDate);
    }

    @ExcelField(title = "续借次数", type = 1, align = 2, sort = 130)
    public String getContCntStr(){
        return contCnt;
    }

    @ExcelField(title = "操作用户", type = 1, align = 2, sort = 140)
    public String getSourceStr(){
        return "self".equals(source) ? "自助" : userName;
    }

    @ExcelField(title = "状态", type = 1, align = 2, sort = 150)
    public String getStatusStr(){
        return DictUtils.getDictLabel(status, "borrow_status", "借出中");
    }
    // -------------------------------------------------------------------------------

    public String getSearchCondition() {
        return searchCondition;
    }

    public void setSearchCondition(String searchCondition) {
        this.searchCondition = searchCondition;
    }

    public BkBookstore getBkBookstore() {
        return bkBookstore;
    }

    public void setBkBookstore(BkBookstore bkBookstore) {
        this.bkBookstore = bkBookstore;
    }

    public String getZlId() {
        return zlId;
    }

    public void setZlId(String zlId) {
        this.zlId = zlId;
    }

    public String getBkId() {
        return bkId;
    }

    public void setBkId(String bkId) {
        this.bkId = bkId;
    }

    public String getRdId() {
        return rdId;
    }

    public void setRdId(String rdId) {
        this.rdId = rdId;
    }

    public Date getBorDate() {
        return borDate;
    }

    public void setBorDate(Date borDate) {
        this.borDate = borDate;
    }

    public Date getRtnDate() {
        return rtnDate;
    }

    public void setRtnDate(Date rtnDate) {
        this.rtnDate = rtnDate;
    }

    public String getContCnt() {
        return contCnt;
    }

    public void setContCnt(String contCnt) {
        this.contCnt = contCnt;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Override
    public String getRemarks() {
        return remarks;
    }

    @Override
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public ReaderRoler getReaderRoler() {
        return readerRoler;
    }

    public void setReaderRoler(ReaderRoler readerRoler) {
        this.readerRoler = readerRoler;
    }

    public Reader getReader() {
        return reader;
    }

    public void setReader(Reader reader) {
        this.reader = reader;
    }

    public BkBookinfo getBkBookinfo() {
        return bkBookinfo;
    }

    public void setBkBookinfo(BkBookinfo bkBookinfo) {
        this.bkBookinfo = bkBookinfo;
    }

    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }
    public String getRdCardno() {
        return rdCardno;
    }

    public void setRdCardno(String rdCardno) {
        this.rdCardno = rdCardno;
    }
    public Borrow(){
    }

    public Date getNeedRtnDate() {
        return needRtnDate;
    }
    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public void setNeedRtnDate(Date needRtnDate) {
        this.needRtnDate = needRtnDate;
    }

    public Date getCurrentDate() {
        return currentDate;
    }

    public void setCurrentDate(Date currentDate) {
        this.currentDate = currentDate;
    }

    public String getSource(){
        return source;
    }

    public void setSource(String source){
        this.source = source;
    }
    public String getRdiccardno() {
        return rdiccardno;
    }

    public void setRdiccardno(String rdiccardno) {
        this.rdiccardno = rdiccardno;
    }
    public String getBookname() {
        return bookname;
    }

    public void setBookname(String bookname) {
        this.bookname = bookname;
    }

    public String getClasscode() {
        return classcode;
    }

    public void setClasscode(String classcode) {
        this.classcode = classcode;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getReadername() {
        return readername;
    }

    public void setReadername(String readername) {
        this.readername = readername;
    }

    public String getRdRoleId() {
        return rdRoleId;
    }

    public void setRdRoleId(String rdRoleId) {
        this.rdRoleId = rdRoleId;
    }

    public String getReturnStatus() {
        return returnStatus;
    }

    public void setReturnStatus(String returnStatus) {
        this.returnStatus = returnStatus;
    }

    @Override
    public String toString() {
        return "Borrow{" +
                "zlId='" + zlId + '\'' +
                ", bkId='" + bkId + '\'' +
                ", rdId='" + rdId + '\'' +
                ", borDate=" + borDate +
                ", rtnDate=" + rtnDate +
                ", contCnt='" + contCnt + '\'' +
                ", userName='" + userName + '\'' +
                ", remarks='" + remarks + '\'' +
                ", status='" + status + '\'' +
                ", returnStatus='" + returnStatus + '\'' +
                ", readerRoler=" + readerRoler +
                ", reader=" + reader +
                '}';
    }
}
